// pages/chooseShop/index.js
const app = getApp();
import Common from '../../../common/common.js';
let common = new Common;
Page({
  data: {
    list: [],
    isIpx: "",
    shopId: '',
    orgList: [],
  },
  radioChange: function(e) {
    this.setData({
      shopId: e.detail.value
    })
  },
  sureShop: function(e) {
    let orgList = this.data.orgList;
    let shopInfo = {}
    for (var i = 0; i < orgList.length; i++) {
      if (this.data.shopId == orgList[i].orgSeq) {
        shopInfo = JSON.parse(JSON.stringify(orgList[i]))
      }
    }
    console.log(shopInfo)
    app.globalData.shopInfo = shopInfo
    app.globalData.orgSeq = this.data.shopId
    console.log('orgSeq', app.globalData.orgSeq)
    console.log('shopInfo', JSON.stringify(app.globalData.shopInfo))
    wx.navigateBack()
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let shopList = app.globalData.orgList;
    this.setData({
      isIpx: app.globalData.isIphoneX,
      list: shopList,
      orgList: app.globalData.orgList,
      checkedIndex:app.globalData.shopInfo.orgSeq,
      shopId: app.globalData.shopInfo.orgSeq,
    })
    console.log(this.data.checkedIndex)
  }
})